package repertory.android.ericchen.androidrepertory.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import repertory.android.ericchen.androidrepertory.R;
import repertory.android.ericchen.androidrepertory.util.NetworkUtils;

/**
 * className:
 * author: Ericchen
 * description:
 * date: 2017/3/8 15:42
 * update: 2017/3/8
 * version:
 */
public class UtilsActivity extends Activity implements View.OnClickListener{
    private Button BtnNetwork;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_utils);
        BtnNetwork = (Button)findViewById(R.id.btn_network);
        BtnNetwork.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_network:
                if(!NetworkUtils.isAvalidNetSetting(getApplicationContext())){
                    Intent intent = new Intent();
                    intent.setAction("android.net.wifi.PICK_WIFI_NETWORK");
                    startActivityForResult(intent,0);
                }else{
                    Toast.makeText(getApplicationContext(),"已连接网络",Toast.LENGTH_SHORT).show();
                }
                break;
        }

    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if(!NetworkUtils.isAvalidNetSetting(getApplicationContext())){
        }else{
            Toast.makeText(getApplicationContext(),"已连接网络",Toast.LENGTH_SHORT).show();
        }
    }
}
